<template>
  <div class="reportFormPage" v-if="show">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">{{ this.form.baobmc }}</div>
        <div class="codeText">
          <tr v-for="(item, index) in form.baobbhList">
            {{
              item
            }}
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>

            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
              <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->
              <td width="35%" class="text-center">
                <el-input v-model="form.shiyjcrq" />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%" />
                ℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%" />
                %RH
              </td>
            </tr>

            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="600px" class="middle-table">
          <tbody>
            <tr>
              <td width="15%" height="50">材料名称</td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc1 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc1" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 0)" @paste.native="handlePaste($event, 0, 0)" :ref="'0_0'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc2 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc2" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 1)" @paste.native="handlePaste($event, 0, 1)" :ref="'0_1'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc3 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc3" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 2)" @paste.native="handlePaste($event, 0, 2)" :ref="'0_2'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc4 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc4" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 3)" @paste.native="handlePaste($event, 0, 3)" :ref="'0_3'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc5 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc5" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 4)" @paste.native="handlePaste($event, 0, 4)" :ref="'0_4'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc6 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc6" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 5)" @paste.native="handlePaste($event, 0, 5)" :ref="'0_5'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc7 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc7" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 6)" @paste.native="handlePaste($event, 0, 6)" :ref="'0_6'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc8 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc8" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 7)" @paste.native="handlePaste($event, 0, 7)" :ref="'0_7'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc9 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc9" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 8)" @paste.native="handlePaste($event, 0, 8)" :ref="'0_8'" />
              </td>
              <td class="td1">
                <span v-if="isPdf">{{ form.cailmc10 }}</span>
                <el-input v-else type="textarea" v-model="form.cailmc10" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 9)" @paste.native="handlePaste($event, 0, 9)" :ref="'0_9'" />
              </td>
              <td class="td3" rowspan="2">级配类型</td>
              <td class="td2" colspan="2" rowspan="2">
                <span v-if="isPdf">{{ form.jiplx }}</span>
                <el-input v-else type="textarea" v-model="form.jiplx" @change="backBgzFun" @keydown.native="handleKeyDown($event, 0, 10)" @paste.native="handlePaste($event, 0, 10)" :ref="'0_10'" />
              </td>
            </tr>
            <tr>
              <td width="15%" height="50">掺配比例(%)</td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb1"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 0)"
                  @paste.native="handlePaste($event, 1, 0)"
                  :ref="'1_0'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb2"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 1)"
                  @paste.native="handlePaste($event, 1, 1)"
                  :ref="'1_1'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb3"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 2)"
                  @paste.native="handlePaste($event, 1, 2)"
                  :ref="'1_2'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb4"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 3)"
                  @paste.native="handlePaste($event, 1, 3)"
                  :ref="'1_3'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb5"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 4)"
                  @paste.native="handlePaste($event, 1, 4)"
                  :ref="'1_4'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb6"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 5)"
                  @paste.native="handlePaste($event, 1, 5)"
                  :ref="'1_5'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb7"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 6)"
                  @paste.native="handlePaste($event, 1, 6)"
                  :ref="'1_6'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb8"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 7)"
                  @paste.native="handlePaste($event, 1, 7)"
                  :ref="'1_7'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb9"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 8)"
                  @paste.native="handlePaste($event, 1, 8)"
                  :ref="'1_8'"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.chanpb10"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, 1, 9)"
                  @paste.native="handlePaste($event, 1, 9)"
                  :ref="'1_9'"
                />
              </td>
            </tr>
            <tr>
              <td width="15%">筛孔尺寸(mm)</td>
              <td colspan="10">累计筛余率(%)</td>
              <td class="td3">合成级配</td>
              <td class="td2" colspan="2">规范要求</td>
            </tr>
            <tr v-for="(item, index) in form.detailList" :key="index">
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shaikcc"
                  @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, index + 2, 0)"
                  @paste.native="handlePasteDetailList($event, index, 0)"
                  :ref="`${index + 2}_0`"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy1"
                  @keydown.native="handleKeyDown($event, index + 2, 1)"
                  @paste.native="handlePasteDetailList($event, index, 1)"
                  :ref="`${index + 2}_1`"
                  @change="computeHecjp(1, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy2"
                  @keydown.native="handleKeyDown($event, index + 2, 2)"
                  @paste.native="handlePasteDetailList($event, index, 2)"
                  :ref="`${index + 2}_2`"
                  @change="computeHecjp(2, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy3"
                  @keydown.native="handleKeyDown($event, index + 2, 3)"
                  @paste.native="handlePasteDetailList($event, index, 3)"
                  :ref="`${index + 2}_3`"
                  @change="computeHecjp(3, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy4"
                  @keydown.native="handleKeyDown($event, index + 2, 4)"
                  @paste.native="handlePasteDetailList($event, index, 4)"
                  :ref="`${index + 2}_4`"
                  @change="computeHecjp(4, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy5"
                  @keydown.native="handleKeyDown($event, index + 2, 5)"
                  @paste.native="handlePasteDetailList($event, index, 5)"
                  :ref="`${index + 2}_5`"
                  @change="computeHecjp(5, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy6"
                  @keydown.native="handleKeyDown($event, index + 2, 6)"
                  @paste.native="handlePasteDetailList($event, index, 6)"
                  :ref="`${index + 2}_6`"
                  @change="computeHecjp(6, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy7"
                  @keydown.native="handleKeyDown($event, index + 2, 7)"
                  @paste.native="handlePasteDetailList($event, index, 7)"
                  :ref="`${index + 2}_7`"
                  @change="computeHecjp(7, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy8"
                  @keydown.native="handleKeyDown($event, index + 2, 8)"
                  @paste.native="handlePasteDetailList($event, index, 8)"
                  :ref="`${index + 2}_8`"
                  @change="computeHecjp(8, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy9"
                  @keydown.native="handleKeyDown($event, index + 2, 9)"
                  @paste.native="handlePasteDetailList($event, index, 9)"
                  :ref="`${index + 2}_9`"
                  @change="computeHecjp(9, index)"
                />
              </td>
              <td class="td1">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.leijsy10"
                  @keydown.native="handleKeyDown($event, index + 2, 10)"
                  @paste.native="handlePasteDetailList($event, index, 10)"
                  :ref="`${index + 2}_10`"
                  @change="computeHecjp(10, index)"
                />
              </td>
              <td class="td3">
                <div>{{ item.hecjp }}</div>
              </td>
              <td class="td4" colspan="2">
                <div class="guifyqClass">
                  <div class="guifyq1">
                    <el-input
                      v-model="item.guifyq"
                      @change="backBgzFun"
                      @keydown.native="handleKeyDown($event, index + 2, 11)"
                      @paste.native="handlePasteDetailList($event, index, 11)"
                      :ref="`${index + 2}_11`"
                    />
                  </div>
                  <div class="lll">～</div>
                  <div class="guifyq1">
                    <el-input
                      v-model="item.guifyq2"
                      @change="backBgzFun"
                      @keydown.native="handleKeyDown($event, index + 2, 12)"
                      @paste.native="handlePasteDetailList($event, index, 12)"
                      :ref="`${index + 2}_12`"
                    />
                  </div>
                </div>

                <!-- <el-input v-model="item.guifyq" @change="backBgzFun"
                  @keydown.native="handleKeyDown($event, index + 2, 11)"
                  @paste.native="handlePasteDetailList($event, index, 11)" :ref="`${index + 2}_11`" /> -->
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="70px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jiancr}} -->
            </td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jilr}} -->
            </td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%">
              <!-- {{this.form.fuhr}} -->
            </td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-right: 30px">年</div>
              <div style="display: inline-block; margin-right: 30px">月</div>
              <div style="display: inline-block">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
  </div>
</template>

<script>
import { handleFocus, emptyConvert, uniqueStr, handleKeyDown, handlePaste } from "@/views/reportForms/utils";
import { getCjlkzhhljlbBsInfo } from "@/api/report_jl/cjl";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

import decimal from "@/utils/big-decimal";
import Bus from "@/utils/bus";

export default {
  name: "cjlhnlzpzjlbTable",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      form: {
        detailList: [],
        baobbhList: []
      },
      backBgz: {},
      show: false,
      showQyxx: false,
      clmcObj: [],
      cpblObj: [],
      skccList: [],
      ljsyList: [],
      tgbflList: [],
      gdzList: [],
      lj1List: [],
      lj2List: [],
      lj3List: [],
      lj4List: [],
      lj5List: [],
      lj6List: [],
      lj7List: [],
      lj8List: [],
      lj9List: [],
      lj10List: []
    };
  },

  computed: {},
  created() {
    this.init();
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    }
  },
  methods: {
    // 根据报表id获取当前报表信息
    init() {
      this.show = false;
      getCjlkzhhljlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
        this.backBgzFun()
        this.setInitialValue();
        this.show = true;
      });
    },
    // 设置初始值
    setInitialValue() {
      if (this.form) {
        this.form.baobmc = this.form.baobmc || "矿质混合料配合组成试验检测记录表";
        this.form.baobbh = this.form.baobbh || "JGLQ02001c";
        this.$set(this.form, "baobbhList", []);
        this.form.baobbhList = ["JGLQ02001c"];
      }
      if (!this.form.detailList || this.form.detailList.length <= 0) {
        this.getDetailList();
      }
    },
    getDetailList() {
      this.$set(this.form, "detailList", []);
      for (let i = 0; i < 14; i++) {
        const detail1 = {
          detailId: null,
          excelId: this.excelId,
          shaikcc: null,
          leijsy1: null,
          leijsy2: null,
          leijsy3: null,
          leijsy4: null,
          leijsy5: null,
          leijsy6: null,
          leijsy7: null,
          leijsy8: null,
          leijsy9: null,
          leijsy10: null,
          hecjp: null,
          guifyq: null
        };
        this.form.detailList.push(detail1);
      }
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setCjlBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setCjlBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
      this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    submitForm() {
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    // 合成级配计算均值
    computeHecjp(type, index) {
      let sum = 0;
      let num = 0;
      if (this.form.detailList[index].leijsy1) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy1));
        num++;
      }
      if (this.form.detailList[index].leijsy2) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy2));
        num++;
      }
      if (this.form.detailList[index].leijsy3) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy3));
        num++;
      }
      if (this.form.detailList[index].leijsy4) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy4));
        num++;
      }
      if (this.form.detailList[index].leijsy5) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy5));
        num++;
      }
      if (this.form.detailList[index].leijsy6) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy6));
        num++;
      }
      if (this.form.detailList[index].leijsy7) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy7));
        num++;
      }
      if (this.form.detailList[index].leijsy8) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy8));
        num++;
      }
      if (this.form.detailList[index].leijsy9) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy9));
        num++;
      }
      if (this.form.detailList[index].leijsy10) {
        sum = decimal.add(sum, Number(this.form.detailList[index].leijsy10));
        num++;
      }
      if (sum && num != 0) {
        this.form.detailList[index].hecjp = decimal.divide(sum, num, 1);
      } else {
        this.form.detailList[index].hecjp = null;
      }
      this.backBgzFun();
    },
    handleArrPa() {
      this.clmcObj = {
        cailmc1: this.form.cailmc1,
        cailmc2: this.form.cailmc2,
        cailmc3: this.form.cailmc3,
        cailmc4: this.form.cailmc4,
        cailmc5: this.form.cailmc5,
        cailmc6: this.form.cailmc6,
        cailmc7: this.form.cailmc7,
        cailmc8: this.form.cailmc8,
        cailmc9: this.form.cailmc9,
        cailmc10: this.form.cailmc10
      };
      this.cpblObj = {
        chanpb1: this.form.chanpb1,
        chanpb2: this.form.chanpb2,
        chanpb3: this.form.chanpb3,
        chanpb4: this.form.chanpb4,
        chanpb5: this.form.chanpb5,
        chanpb6: this.form.chanpb6,
        chanpb7: this.form.chanpb7,
        chanpb8: this.form.chanpb8,
        chanpb9: this.form.chanpb9,
        chanpb10: this.form.chanpb10
      };

      let arr = this.form.detailList;
      this.skccList = [];
      this.ljsyList = [];
      this.tgbflList = [];
      this.gdzList = [];

      this.lj1List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj2List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj3List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj4List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj5List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj6List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj7List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj8List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj9List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];
      this.lj10List = [null, null, null, null, null, null, null, null, null, null, null, null, null, null];

      for (let i = 0; i < arr.length; i++) {
        if (arr[i].shaikcc) {
          this.skccList.push(arr[i].shaikcc);
          this.ljsyList.push(arr[i].hecjp);
          this.tgbflList.push(arr[i].hecjp ? decimal.subtract(100, arr[i].hecjp, 1) : null);
          this.gdzList.push(arr[i].guifyq);

          // 用于生成报告中图表的虚线值 累计筛余列数...
          this.lj1List.splice(i, 1, arr[i].leijsy1);
          this.lj2List.splice(i, 1, arr[i].leijsy2);
          this.lj3List.splice(i, 1, arr[i].leijsy3);
          this.lj4List.splice(i, 1, arr[i].leijsy4);
          this.lj5List.splice(i, 1, arr[i].leijsy5);
          this.lj6List.splice(i, 1, arr[i].leijsy6);
          this.lj7List.splice(i, 1, arr[i].leijsy7);
          this.lj8List.splice(i, 1, arr[i].leijsy8);
          this.lj9List.splice(i, 1, arr[i].leijsy9);
          this.lj10List.splice(i, 1, arr[i].leijsy10);
        }
      }
    },
    // 返回报告引入值
    backBgzFun() {
      this.handleArrPa();
      Bus.$emit("setCjlKzBgData", {
        clmcObj: this.clmcObj,
        cpblObj: this.cpblObj,
        skccList: this.skccList,
        ljsyList: this.ljsyList,
        tgbflList: this.tgbflList,
        gdzList: this.gdzList,
        lj1List: this.lj1List,
        lj2List: this.lj2List,
        lj3List: this.lj3List,
        lj4List: this.lj4List,
        lj5List: this.lj5List,
        lj6List: this.lj6List,
        lj7List: this.lj7List,
        lj8List: this.lj8List,
        lj9List: this.lj9List,
        lj10List: this.lj10List
      });
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [10, 9, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]; // 每一行最多有多少可聚焦输入框（从0开始）
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]?.length) {
        this.$refs[ref][0].focus();
      } else if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    },
    // 粘贴赋值方法
    handlePaste(event, rowIndex, colIndex) {
      const nameAllArr = [
        ["cailmc1", "cailmc2", "cailmc3", "cailmc4", "cailmc5", "cailmc6", "cailmc7", "cailmc8", "cailmc9", "cailmc10"],

        ["chanpb1", "chanpb2", "chanpb3", "chanpb4", "chanpb5", "chanpb6", "chanpb7", "chanpb8", "chanpb9", "chanpb10"]
      ];
      const subscriptArr = [
        [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
        [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      ];

      const methodsAllArr = [
        ["backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun"],
        ["backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun", "backBgzFun"]
      ];
      const parameterArr = [
        [null, null, null, null, null, null, null, null, null, null],
        [null, null, null, null, null, null, null, null, null, null]
      ];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
        }
      }
    },

    // detailList粘贴赋值方法
    handlePasteDetailList(event, rowIndex, colIndex) {
      const nameAllArr = this.form.detailList.map((item, index) => {
        return ["shaikcc", "leijsy1", "leijsy2", "leijsy3", "leijsy4", "leijsy5", "leijsy6", "leijsy7", "leijsy8", "leijsy9", "leijsy10", "guifyq"];
      });
      const subscriptArr = this.form.detailList.map((item, index) => {
        return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
      });
      const methodsAllArr = this.form.detailList.map((item, index) => {
        return [
          "backBgzFun",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "computeHecjp",
          "backBgzFun"
        ];
      });
      const parameterArr = this.form.detailList.map((item, index) => {
        return [null, "1-" + index, "2-" + index, "3-" + index, "4-" + index, "5-" + index, "6-" + index, "7-" + index, "8-" + index, "9-" + index, "10-" + index, null];
      });

      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form.detailList[rowIndex + a][nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          let methods = methodsSetArr[a][b];
          if (methods == "computeHecjp") {
            console.log(methods);
            let parameter = parameterSetArr[a][b];
            let parameterArr = parameter ? parameter.split("-") : [];
            if (parameterArr.length >= 2) {
              this.setCalculate(methodsSetArr[a][b], parameterArr[0], parameterArr[1]);
            }
          } else {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 计算方法调用
    setCalculate(name, a, b, c, d, e) {
      this[name](a, b, c, d, e);
    }
  }
};
</script>

<style scoped lang="scss">
.td1 {
  // width: calc(85% / 12 * 1);
  width: calc(68% / 10 * 1);
  // 15+12+5 =32
}

.td2 {
  width: 12%;
  // width: calc(85% / 12 * 2);
}
.td3 {
  width: 5%;
}
.td4 {
  .guifyqClass {
    display: flex;
    height: 28px;
    background: #ffffff;
    .lll {
      width: 20%;
      line-height: 28px;
      background: #ffffff;
    }
    .guifyq1 {
      width: 40%;
    }
  }
  .td4 > div {
    display: flex;
  }
}
</style>
